package com.xw.util;


import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ReadConverterContext;
import com.alibaba.excel.converters.WriteConverterContext;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.xw.common.RoleEnum;

/**
 * @Description: TODO
 * @Author: 72478
 * @Date: 2024/12/20 09:20
 * @Version: 1.0
 */
public class RoleConverter implements Converter<String> {
    /**
     * 导入转换
     *
     * @param context
     * @return
     */
    @Override
    public String convertToJavaData(ReadConverterContext<?> context) {
        return
                RoleEnum.getCodeByDesc(context.getReadCellData().getStringValue());
    }
    /**
     * 导出转换
     *
     * @param context
     * @return
     */
    @Override
    public WriteCellData<?> convertToExcelData(WriteConverterContext<String>
                                                       context) {
        return new WriteCellData<>(RoleEnum.getDescByCode(context.getValue()));
    }
}

